﻿using System.Collections.Generic;
using Azure.QPCR;

namespace Azure2Java.QPCRAdapter.Adapter.Entity {
    /**
     * @authod zy
     * @date 12.21
     * @decription ProgramStep代理类
     */
    public class ProgramStepBean {
        public ProgramStep ProgramStep;

        public ProgramStepBean(int stepName) {
            ProgramStep = new ProgramStep((ushort) stepName);
        }

        public ProgramStepBean(ProgramStep ProgramStep) {
            this.ProgramStep = ProgramStep;
        }

        /* Step Name            */
        /* 0x0000 - 0x0001 */
        public void setName(ushort name) { ProgramStep.Name = name; }

        public ushort getName() { return ProgramStep.Name; }

        /* Step Function        */
        public void setFunction(ushort function) { ProgramStep.Function = function; }

        public ushort getFunction() { return ProgramStep.Function; }

        /* Step Holding time    */
        public void setHoldTime(uint holdTime) { ProgramStep.HoldTime = holdTime; }

        public uint getHoldTime() { return ProgramStep.HoldTime; }

        /* Step Forever         */
        public void setForever(ushort forever) { ProgramStep.Forever = forever; }

        public ushort getForver() { return ProgramStep.Forever; }

        /* Ramp Rate       *//* Ramp Rate       */
        public void setRampRate(ushort rampRate) { ProgramStep.RampRate = rampRate; }

        public ushort getRampRate() { return ProgramStep.RampRate; }

        /* Every cycle Step delta Temperature      */
        public void setDeltaTemperature(short deltaTemperature) {  ProgramStep.DeltaTemp = deltaTemperature; }

        public short getDeltaTemperature() { return ProgramStep.DeltaTemp; }

        /* Every cycle Step delta Time      */
        public void setDeltaTime(short deltaTime) { ProgramStep.DeltaTime = deltaTime; }

        public short getDeltaTime() { return ProgramStep.DeltaTime; }

        /*  Step which gotoes      */
        public void setToStep(ushort toStep) { ProgramStep.ToStep = toStep; }

        public ushort getToStep() { return ProgramStep.ToStep; }

        /* times which goto            */
        public void setGotoTimes(ushort gotoTimes) { ProgramStep.GotoTimes = gotoTimes; }

        public ushort getGotoTimes() { return ProgramStep.GotoTimes; }

        /* Step Auto Pause before */
        public void setPauseBefore(ushort pauseBefore) { ProgramStep.PauseBefore = pauseBefore; }

        public ushort getPauseBefore() { return ProgramStep.PauseBefore; }

        /* Step Auto Pause After  */
        public void setPauseAfter(ushort pauseAfter) { ProgramStep.PauseAfter = pauseAfter; }

        public ushort getPauseAfter() { return ProgramStep.PauseAfter; }

        /*loop nesting times*/
        public void setLoopNestingTimes(ushort loopNestingTimes) { ProgramStep.LoopNestingTimes = loopNestingTimes; }

        public ushort getLoopNestingTimes() { return ProgramStep.LoopNestingTimes; }

        /* 0x0000: DISABLE; 0x0001: NORMAL;0x0002: 
         * Melting Curve;   0x0003 HR Melting Curve  */
        public void setCollectedMode(ushort collectedMode) { ProgramStep.CollectedMode = collectedMode; }

        public ushort getCollectedMode() { return ProgramStep.CollectedMode; }

        /* Step NC              */
        public void setNC(short[] nc) {
            List<ushort> temp = new List<ushort>();
            foreach(var item in nc) {
                temp.Add((ushort) item);
            }
            ProgramStep.NC = temp.ToArray();
        }

        public short[] getNC() {
            List<short> result = new List<short>();
            foreach(var item in ProgramStep.NC) {
                result.Add((short) item);
            }
            return result.ToArray();
        }

        /* Step Temperature     */
        public void setTemperature(short[] temperature) { ProgramStep.Temperature = temperature; }

        public short[] getTemperature() { return ProgramStep.Temperature; }


        public void enableTemperature() { ProgramStep.Function |= 0x0001; }

        public void enableGragient() { ProgramStep.Function |= 0x0001 << 1; }

        public void enableGoTo() { ProgramStep.Function |= 0x0001 << 2; }

        public void enablePidSpeed() { ProgramStep.Function |= 0x0001 << 8; }

        public void enableDTemperature() { ProgramStep.Function |= 0x0001 << 9; }

        public void enableDtime() { ProgramStep.Function |= 0x0001 << 10; }

        public void enablePause() { ProgramStep.Function |= 0x0001 << 12; }

        public void enableIsForever() { ProgramStep.Function |= 0x0001 << 13; }
    }
}
